#include<bits/stdc++.h>
using namespace std;
inline long long read()
{
    long long x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
        if(ch == '-')f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
        x = x * 10 + ch - 48;
        ch = getchar();
    }
    return x * f;
}
long long gcd(long long a, long long b)
{
    if(a % b == 0)return b;
    else return gcd(b, a % b);
}
long long an, bn, op, x, y, n, k;
int main()
{
    n = read();
    an = 0;
    bn = 1;
    for(long long i = 1; i <= n; i++)
    {
        x = read();
        y = read();
        op = read();
        if(op == 1)an = an * y + x * bn;
        else an = an * y - x * bn;
        bn = bn * y;
        k = gcd(an, bn);
        an = an / k;
        bn = bn / k;
    }
    if(an % bn == 0)cout << an / bn;
    else if(an > 0 && bn < 0)cout << -an << "/" << -bn;
    else cout << an << "/" << bn;
    return 0;
}